# 阶段 1: 安装依赖并构建
FROM node:20 AS builder

WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile --production=false
COPY . .
RUN yarn build

# 阶段 2: 生产环境运行
FROM node:20

WORKDIR /app
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json .
COPY --from=builder /app/dist ./dist

CMD ["yarn", "start:prod"]